import {nanoid} from 'nanoid';
import request, { MockResult } from '../request'
const baseUrl = '/spd-eatonos-service'

export const auth = {
  // 获取菜单
  getMenuList (data) {
    return request({
      url: baseUrl + '/auth/getMenuList',
      method: 'post',
      data,
      mock: {
        useMock: true,
        data: MockResult.success([
          {
            path: '/index'
          },
          {
            path: '/next/first',
            children: [
              {
                path: '/next/first/home'
              }
            ]
          },
          {
            path: '/dashboard/index'
          },
          {
            path: '/Maps/index'
          },
          {
            path: '/charts/index'
          }
        ])
      }
    })
  },
  // 登录
  login (data) {
    return request({
      url: baseUrl + '/auth/login',
      method: 'post',
      data,
      mock: {
        useMock: true,
        data: MockResult.success(
          {
            token: '1111'
          }
        )
      }
    })
  },
  // 获取用户信息
  getUserInfo (data) {
    return request({
      url: baseUrl + '/auth/getUserInfo',
      method: 'post',
      data,
      mock: {
        useMock: true,
        data: MockResult.success(
          {
            id: nanoid(),
            name: '胡栋栋',
            age: 27,
            isAdmin: true,
            role: 'admin',
            profile: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.jj20.com%2Fup%2Fallimg%2F511%2F101611154647%2F111016154647-10-1200.jpg&refer=http%3A%2F%2Fimg.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1660136882&t=686a25eef6191e4738c6c94071f1641c',
            email: '120392111@qq.com'
          }
        )
      }
    })
  }
}

export default auth